//
//  PdfHomePdfChangeCell.m

#import "PdfHomePdfChangeCell.h"
#import "PdfHomeSigleView.h"
static NSString * PdfHomePdfChangeCellId = @"PdfHomePdfChangeCellId";
@interface PdfHomePdfChangeCell()
@property (nonatomic,strong) PdfHomeSigleView *pdfHomeSigleWorldView;
@property (nonatomic,strong) PdfHomeSigleView *pdfHomeSigleExcelView;
@property (nonatomic,strong) PdfHomeSigleView *pdfHomeSiglePptView;
@property (nonatomic,strong) PdfHomeSigleView *pdfHomeSigleTxtView;
@end
@implementation PdfHomePdfChangeCell
+ (instancetype)pdfHomePdfChangeCell:(UITableView *)tableView{
    PdfHomePdfChangeCell * pdfHomePdfChangeCell = [tableView dequeueReusableCellWithIdentifier:PdfHomePdfChangeCellId];
    if (!pdfHomePdfChangeCell) {
        pdfHomePdfChangeCell = [[PdfHomePdfChangeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:PdfHomePdfChangeCellId];
    }
    pdfHomePdfChangeCell.backgroundColor = [UIColor clearColor];
    pdfHomePdfChangeCell.selectionStyle = UITableViewCellSelectionStyleNone;
    pdfHomePdfChangeCell.accessoryType = UITableViewCellAccessoryNone;
    return pdfHomePdfChangeCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self makeSubView];
    }
    return self;
}
- (void)makeSubView{
    PdfWeakSelf
    UIView * pdfHomePdfChangeBgView = [[UIView alloc] init];
    pdfHomePdfChangeBgView.backgroundColor = PdfHex(@"#FFFFFF");
    pdfHomePdfChangeBgView.layer.cornerRadius = PdfRatio(10);
    pdfHomePdfChangeBgView.clipsToBounds = YES;
    [self.contentView addSubview:pdfHomePdfChangeBgView];
    [pdfHomePdfChangeBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(24)));
        make.right.equalTo(@(-PdfRatio(24)));
        make.top.equalTo(@(PdfRatio(0)));
        make.bottom.equalTo(@(-PdfRatio(24)));
    }];
    UILabel * pdfHomePdfChangeHeadLab = [[UILabel alloc] init];
    pdfHomePdfChangeHeadLab.text = @"PDF转其他格式";
    pdfHomePdfChangeHeadLab.textColor = PdfHex(@"#0E0E0E");
    pdfHomePdfChangeHeadLab.font = [UIFont systemFontOfSize:PdfRatio(30) weight:UIFontWeightBold];
    [pdfHomePdfChangeBgView addSubview:pdfHomePdfChangeHeadLab];
    [pdfHomePdfChangeHeadLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(23)));
        make.top.equalTo(@(PdfRatio(24)));
        make.height.equalTo(@(PdfRatio(42)));
    }];
    CGFloat sigleWidth = (PdfScreenWidth - PdfRatio(62))/4;
    self.pdfHomeSigleWorldView = [[PdfHomeSigleView alloc] init];
    self.pdfHomeSigleWorldView.pdfHomeSigleType = PdfHomeSigleTypeWorld;
    [pdfHomePdfChangeBgView addSubview:self.pdfHomeSigleWorldView];
    [self.pdfHomeSigleWorldView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(7)));
        make.top.equalTo(pdfHomePdfChangeHeadLab.mas_bottom).offset(PdfRatio(36));
        make.bottom.equalTo(@(PdfRatio(0)));
        make.width.equalTo(@(sigleWidth));
    }];
    self.pdfHomeSigleWorldView.TapHomeTypeBlock = ^(PdfHomeSigleType pdfHomeSigleType) {
        if (weakSelf.TapHomeTypeBlock) {
            weakSelf.TapHomeTypeBlock(pdfHomeSigleType);
        }
    };
    self.pdfHomeSigleExcelView = [[PdfHomeSigleView alloc] init];
    self.pdfHomeSigleExcelView.pdfHomeSigleType = PdfHomeSigleTypeExcel;
    [pdfHomePdfChangeBgView addSubview:self.pdfHomeSigleExcelView];
    [self.pdfHomeSigleExcelView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.pdfHomeSigleWorldView.mas_right);
        make.top.equalTo(self.pdfHomeSigleWorldView);
        make.bottom.equalTo(self.pdfHomeSigleWorldView);
        make.width.equalTo(self.pdfHomeSigleWorldView);
    }];
    self.pdfHomeSigleExcelView.TapHomeTypeBlock = ^(PdfHomeSigleType pdfHomeSigleType) {
        if (weakSelf.TapHomeTypeBlock) {
            weakSelf.TapHomeTypeBlock(pdfHomeSigleType);
        }
    };
    self.pdfHomeSiglePptView = [[PdfHomeSigleView alloc] init];
    self.pdfHomeSiglePptView.pdfHomeSigleType = PdfHomeSigleTypePpt;
    [pdfHomePdfChangeBgView addSubview:self.pdfHomeSiglePptView];
    [self.pdfHomeSiglePptView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.pdfHomeSigleExcelView.mas_right);
        make.top.equalTo(self.pdfHomeSigleWorldView);
        make.bottom.equalTo(self.pdfHomeSigleWorldView);
        make.width.equalTo(self.pdfHomeSigleWorldView);
    }];
    self.pdfHomeSiglePptView.TapHomeTypeBlock = ^(PdfHomeSigleType pdfHomeSigleType) {
        if (weakSelf.TapHomeTypeBlock) {
            weakSelf.TapHomeTypeBlock(pdfHomeSigleType);
        }
    };
    self.pdfHomeSigleTxtView = [[PdfHomeSigleView alloc] init];
    self.pdfHomeSigleTxtView.pdfHomeSigleType = PdfHomeSigleTypeTxt;
    [pdfHomePdfChangeBgView addSubview:self.pdfHomeSigleTxtView];
    [self.pdfHomeSigleTxtView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.pdfHomeSiglePptView.mas_right);
        make.top.equalTo(self.pdfHomeSigleWorldView);
        make.bottom.equalTo(self.pdfHomeSigleWorldView);
        make.width.equalTo(self.pdfHomeSigleWorldView);
    }];
    self.pdfHomeSigleTxtView.TapHomeTypeBlock = ^(PdfHomeSigleType pdfHomeSigleType) {
        if (weakSelf.TapHomeTypeBlock) {
            weakSelf.TapHomeTypeBlock(pdfHomeSigleType);
        }
    };
    UIButton * pdfHomeSigleFilePdfBtn = [[UIButton alloc] init];
    [pdfHomeSigleFilePdfBtn setBackgroundImage:[UIImage imageNamed:@"pdfHomeSigleFilePdf"] forState:UIControlStateNormal];
    [pdfHomeSigleFilePdfBtn addTarget:self action:@selector(pdfHomeSigleFilePdf) forControlEvents:UIControlEventTouchUpInside];
    [pdfHomePdfChangeBgView addSubview:pdfHomeSigleFilePdfBtn];
    [pdfHomeSigleFilePdfBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.bottom.equalTo(@(-PdfRatio(29)));
        make.width.equalTo(@(PdfRatio(652)));
        make.height.equalTo(@(PdfRatio(119)));
    }];
}
- (void)pdfHomeSigleFilePdf{
    if (self.TapHomePdfFileBlock) {
        self.TapHomePdfFileBlock();
    }
}
@end
